package org.zw.android.framework.app;

import android.app.Activity;
import android.view.View;

/**
 * View Util
 * 
 * @author zhouwei
 * 
 */
public final class AppViewUtil {

	@SuppressWarnings("unchecked")
	public static <T> T findViewById(View root, int rid) {

		if (root == null)
			return null;

		try {
			return (T) root.findViewById(rid);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}

	@SuppressWarnings("unchecked")
	public static <T> T findViewById(Activity activity, int rid) {

		if (activity == null)
			return null;

		try {
			return (T) activity.findViewById(rid);
		} catch (Exception e) {
			e.printStackTrace();
		}

		return null;
	}
}
